//
//  HTLibraryView.swift
//  MagaCore
//
//  Created by 谢 on 2024/8/21.
//

import SwiftUI

struct HTLibraryView: View {
    //是否登录
    var var_isLogin = true
    var body: some View {
        VStack(spacing: 0) {
            HStack(spacing: 20) {
                Spacer()
                NavigationLink(destination: HTFeedbackView()) {
                    Image("library_edit")
                        .resizable()
                        .frame(width: 22, height: 22)
                }
                
                NavigationLink(destination: HTSettingView()) {
                    Image("library_set")
                        .resizable()
                        .frame(width: 22, height: 22)
                }
            }
            .padding(.horizontal, 14)
            .padding(.vertical, 14)
            .background(.white)
            
            ScrollView(showsIndicators: false) {
                VStack(spacing: 0) {
                    HStack(spacing: 0) {
                        if var_isLogin {
                            NavigationLink {
                                HTProfileView()
                            } label: {
                                Image("library_default_avatar")
                                    .resizable()
                                    .frame(width: 50, height: 50)
                            }
                            
                            Text("Marty")
                                .font(.system(size: 20, weight: .heavy))
                                .foregroundStyle(Color(hex: "#393939"))
                                .padding(.leading, 10)
                            
                            Spacer()
                        }else{
                            Spacer()
                            Text("Login")
                                .font(.system(size: 14, weight: .heavy))
                                .foregroundStyle(.white)
                                .frame(width: 160, height: 40)
                                .background(Color(hex: "#FF6C3C"))
                                .clipShape(RoundedRectangle(cornerRadius: 40/2.0))
                                .onTapGesture {
                                    print("登录")
                                }
                            Spacer()
                        }
                    }
                    .padding(.top, 24)
                    // 跳转最近播放
                    NavigationLink(destination: HTRecentPlayScreen()) {
                        HStack(spacing: 0) {
                            Image("library_recently")
                                .resizable()
                                .frame(width: 22, height: 22)
                            
                            Text("Recently Played")
                                .font(.system(size: 14, weight: .heavy))
                                .foregroundStyle(Color(hex: "#393939"))
                                .padding(.leading, 10)
                            
                            Spacer()
                        }
                        .padding(.horizontal, 14)
                        .padding(.vertical, 18)
                        .background(.white)
                        .clipShape(RoundedRectangle(cornerRadius: 8))
                        .padding(.top, 22)
                    }
                    
                    HStack(spacing: 0) {
                        ZStack(alignment: .topTrailing) {
                            Image("library_watch")
                                .resizable()
                                .frame(width: 22, height: 22)
                            
                            RoundedRectangle(cornerRadius: 6/2)
                                .frame(width: 6, height: 6)
                                .foregroundStyle(Color(hex: "#FC0B52"))
                                .offset(x: 2, y: -4)
                        }
                        .frame(width: 22, height: 22)
                        
                        Text("My Watchlist")
                            .font(.system(size: 14, weight: .heavy))
                            .foregroundStyle(Color(hex: "#393939"))
                            .padding(.leading, 10)
                        
                        Spacer()
                    }
                    .padding(.horizontal, 14)
                    .padding(.vertical, 18)
                    .background(.white)
                    .clipShape(RoundedRectangle(cornerRadius: 8))
                    .padding(.top, 10)
                }
                .padding(.horizontal, 14)
            }
        }
        .background(content: {
            Color(hex: "#F8F8F8")
        })
    }
}
